﻿<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="class.files/filelist.xml">
<title>Classes</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>think</o:Author>
  <o:LastAuthor>MC SYSTEM</o:LastAuthor>
  <o:Revision>43</o:Revision>
  <o:TotalTime>89</o:TotalTime>
  <o:Created>2014-03-05T07:24:00Z</o:Created>
  <o:LastSaved>2014-10-19T23:35:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>718</o:Words>
  <o:Characters>4095</o:Characters>
  <o:Lines>34</o:Lines>
  <o:Paragraphs>9</o:Paragraphs>
  <o:CharactersWithSpaces>4804</o:CharactersWithSpaces>
  <o:Version>11.5606</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"MS Mincho";
	panose-1:2 2 6 9 4 2 5 8 3 4;
	mso-font-alt:"ＭＳ 明朝";
	mso-font-charset:128;
	mso-generic-font-family:modern;
	mso-font-pitch:fixed;
	mso-font-signature:-536870145 1791491579 18 0 131231 0;}
@font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-alt:SimSun;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
	{font-family:"\@宋体";
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
	{font-family:"\@MS Mincho";
	panose-1:2 2 6 9 4 2 5 8 3 4;
	mso-font-charset:128;
	mso-generic-font-family:modern;
	mso-font-pitch:fixed;
	mso-font-signature:-536870145 1791491579 18 0 131231 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
h4
	{mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:4;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;
	font-weight:bold;}
h5
	{mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:5;
	font-size:10.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;
	font-weight:bold;}
h6
	{mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:6;
	font-size:7.5pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;
	font-weight:bold;}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
p
	{mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
code
	{mso-ansi-font-size:12.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:宋体;
	mso-ascii-font-family:宋体;
	mso-fareast-font-family:宋体;
	mso-hansi-font-family:宋体;
	mso-bidi-font-family:宋体;}
pre
	{margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
span.apple-converted-space
	{mso-style-name:apple-converted-space;}
span.dcomment
	{mso-style-name:d_comment;}
span.dhata
	{mso-style-name:d_hata;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:42.55pt;
	mso-footer-margin:49.6pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:214465320;
	mso-list-template-ids:-466027386;}
@list l0:level1
	{mso-level-number-format:bullet;
	mso-level-text:;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l0:level2
	{mso-level-tab-stop:72.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l0:level3
	{mso-level-tab-stop:108.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l0:level4
	{mso-level-tab-stop:144.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l0:level5
	{mso-level-tab-stop:180.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l0:level6
	{mso-level-tab-stop:216.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l0:level7
	{mso-level-tab-stop:252.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l0:level8
	{mso-level-tab-stop:288.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l0:level9
	{mso-level-tab-stop:324.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1
	{mso-list-id:932320071;
	mso-list-template-ids:-1758281792;}
@list l1:level1
	{mso-level-number-format:bullet;
	mso-level-text:;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l1:level2
	{mso-level-tab-stop:72.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level3
	{mso-level-tab-stop:108.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level4
	{mso-level-tab-stop:144.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level5
	{mso-level-tab-stop:180.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level6
	{mso-level-tab-stop:216.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level7
	{mso-level-tab-stop:252.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level8
	{mso-level-tab-stop:288.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l1:level9
	{mso-level-tab-stop:324.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="6146"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=ZH-CN link=blue vlink=blue style='tab-interval:21.0pt'>

<div class=Section1>

<h4 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;vertical-align:baseline'><span style='font-size:18.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>类</span><span
lang=EN-US style='font-size:18.0pt;font-family:Arial;color:#000033'><o:p></o:p></span></h4>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline;
outline: 0px;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;
background-position:initial initial;background-repeat:initial initial;
word-spacing:0px'>与结构相似<span lang=EN-US>,</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span style='font-size:
14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>类</span></b></code>具有定义新类型的功能<span lang=EN-US>. </span>跟结构不同的是<span
lang=EN-US>, </span>在<span lang=EN-US>D</span>语言中，类提供<span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>面向对象编程</span><span lang=EN-US>(OOP)
</span>模型。<span lang=EN-US> OOP </span>的主要方面如下所示：</p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>•</span><b><span
style='border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>封装<span lang=EN-US>:</span></span></b><span lang=EN-US
style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>控制对成员的访问</span><span
style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>（结构也能使用封装，到本章才提及）</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>•</span><span
style='font-family:"Times New Roman";color:black'> </span><b><span
style='border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>继承<span lang=EN-US>:</span></span></b><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>获得另一个类型的成员</span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:192.0pt;margin-bottom:
0cm;margin-left:6.0pt;margin-bottom:.0001pt;mso-para-margin-top:0cm;mso-para-margin-right:
192.0pt;mso-para-margin-bottom:0cm;mso-para-margin-left:.5gd;mso-para-margin-bottom:
.0001pt;line-height:14.25pt;vertical-align:baseline'><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>•</span><span style='font-family:"Times New Roman";
color:black'> </span><b><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>多态性</span></b><b><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>:</span></b><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>使用一种更特殊类型来替代更通用的类型</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline;
outline: 0px;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;
background-position:initial initial;background-repeat:initial initial;
word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>通过<i><span style='border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>保护属性</span></i>来实现封装，下一章中将会看到。继承是获得其他类型的<i><span
style='border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>实现</span></i>。多态性是从多个类中抽象出的部分代码，通过<i><span style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>接口</span></i>来实现。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>这一章将深入介绍类，重点强调类是引用类型。稍后的章节中将展示类的更多细节。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><span
style='mso-spacerun:yes'>    </span><o:p></o:p></span></p>

<h5 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;vertical-align:baseline'><span style='font-size:15.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>与结构比较</span><span
lang=EN-US style='font-size:15.0pt;font-family:Arial;color:#000033'><o:p></o:p></span></h5>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;vertical-align:baseline;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>通常情况下，类与结构非常相似。下面的适用于结构的大部分特性同样适于类：</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Symbol;
mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol;color:black'><span
style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span lang=EN-US style='font-family:"Times New Roman";
color:black'><a href="http://ddili.org/ders/d.en/struct.html"><span lang=EN-US
style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";color:purple;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:none'><span
lang=EN-US>结构</span></span></a><o:p></o:p></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Symbol;
mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol;color:black'><span
style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span lang=EN-US style='font-family:"Times New Roman";
color:black'><a href="http://ddili.org/ders/d.en/member_functions.html"
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><span lang=EN-US>成员函数</span></span></a><o:p></o:p></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Symbol;
mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol;color:black'><span
style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span lang=EN-US style='font-family:"Times New Roman";
color:black'><a href="http://ddili.org/ders/d.en/const_member_functions.html"
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
style='font-size:14.5pt;color:purple;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:none'>const
ref</span></b></code><span lang=EN-US style='font-family:宋体;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'><span lang=EN-US>参数</span></span><span
lang=EN-US style='color:purple;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:none'><span
lang=EN-US> </span></span><span lang=EN-US style='font-family:宋体;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'><span lang=EN-US>和</span></span><span
class=apple-converted-space><span style='color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'>&nbsp;</span></span><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span style='font-size:14.5pt;color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'>const</span></b></code><span
class=apple-converted-space><span style='color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'>&nbsp;</span></span><span lang=EN-US style='font-family:宋体;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'><span lang=EN-US>成员函数</span></span></a><o:p></o:p></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Symbol;
mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol;color:black'><span
style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span lang=EN-US style='font-family:"Times New Roman";
color:black'><a href="http://ddili.org/ders/d.en/special_functions.html"
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><span lang=EN-US>构造函数和其它特殊函数</span></span></a><o:p></o:p></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Symbol;
mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol;color:black'><span
style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span lang=EN-US style='font-family:"Times New Roman";
color:black'><a href="http://ddili.org/ders/d.en/operator_overloading.html"
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><span lang=EN-US>运算符重载</span></span></a><o:p></o:p></span></p>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;vertical-align:baseline;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>然而，类与结构之间仍有重要区别。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><b><span
style='font-size:13.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;color:#000033'>类是引用类型</span></b><b><span lang=EN-US
style='font-size:13.0pt;font-family:Arial;color:#000033'><o:p></o:p></span></b></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><b><span
lang=EN-US style='font-size:13.0pt;font-family:Arial;color:#000033'><o:p>&nbsp;</o:p></span></b></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'>与结构的最大不同是结构是<span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><i style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>值类型</span></i>，类是<i><span
style='border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>引用类型</span></i>。<span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>下面的其它不同大部分与此有关。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><b><span
style='font-size:13.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;color:#000033'>类对象可以是</span></b><span
class=apple-converted-space><span style='font-size:13.0pt;font-family:Arial;
color:#000033'> </span></span><code style='OUTLINE-WIDTH: 0px'><span
lang=EN-US style='font-size:15.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>null<o:p></o:p></span></code></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><b><span
lang=EN-US style='font-size:13.0pt;font-family:Arial;color:#000033'><o:p>&nbsp;</o:p></span></b></p>

<p style='margin-top:5.0pt;margin-right:12.0pt;margin-bottom:5.0pt;margin-left:
12.0pt;line-height:14.25pt;vertical-align:baseline'><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>在</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><a
href="http://ddili.org/ders/d.en/null_is.html" style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><code><b><span
style='font-size:14.5pt;color:purple;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:none'>null</span></b></code><span
class=apple-converted-space><span style='color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'>&nbsp;</span></span><span lang=EN-US style='font-family:宋体;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'><span lang=EN-US>值和</span></span><span
class=apple-converted-space><span style='color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'>&nbsp;</span></span><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span style='font-size:14.5pt;color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'>is</span></b></code><span
class=apple-converted-space><span style='color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'>&nbsp;</span></span><span lang=EN-US style='font-family:宋体;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'><span lang=EN-US>运算符章节</span></span></a>,
</span><span style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";color:black'>本书已简单的提到，类变量能为</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>null</span></b></code><span lang=EN-US
style='font-family:"Times New Roman";color:black'>. </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>换加话说</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>,</span><span
lang=EN-US> </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>类变量可以不提供对任何对象的访问。类变量没有值本身</span><span lang=EN-US style='font-family:
"Times New Roman";color:black'>; </span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>实际的类对象必须由</span><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>new</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>关键字构造。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;vertical-align:baseline'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>你还会记得，一个引用与</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>null</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>通过</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>==</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>或者</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>!=</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>运算符比较是一个错误。相反，必须用</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>is</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>或者</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>!is</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>运算符做比较，因此：</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'><o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span>MyClass referencesAnObject = </span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>new</span></span><span
lang=EN-US style='color:black'> MyClass;<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>assert</span><span lang=EN-US
style='color:black'>(</span><span lang=EN-US>referencesAnObject </span></span><span
lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;background:#FFFF88'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'>!is</span></span><span
lang=EN-US style='color:black'> </span><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'>null</span></span><span lang=EN-US
style='color:black'>);<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span>MyClass variable;<span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>// </span><span
style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>没有引用一个变量<span lang=EN-US><o:p></o:p></span></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>assert</span><span lang=EN-US
style='color:black'>(</span><span lang=EN-US>variable </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>is</span></span></span><span
lang=EN-US style='color:black'> </span><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'>null</span></span><span lang=EN-US
style='color:black'>);<o:p></o:p></span></pre></div>

<p style='margin-top:5.0pt;margin-right:12.0pt;margin-bottom:5.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>原因是，这个</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>==</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>运算符</span><span
style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>会查询对象成员的值，并尝试访问成员，若变量为</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>null</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>，</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>则会引发内存访问错误。</span><span style='font-family:"Times New Roman";
color:black'> </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>因此，类变量必须总是使用</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>is</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>and</span><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>!is</span></b></code><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>运算符做比较。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><b><span style='font-size:13.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>类变量与类对象</span></b><b><span
lang=EN-US style='font-size:13.0pt;font-family:Arial;color:#000033'><o:p></o:p></span></b></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>类变量和类对象是单独的概念。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>类对象由</span><span style='font-family:"Times New Roman";color:black'>
<span class=apple-converted-space><span lang=EN-US>&nbsp;</span></span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>new</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>关键字构造；它们没有名子。在程序中，一个类类型用一个类对象表示。比如，一个</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>Student</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>类用</span></span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> names </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>和</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> grades</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>表示学生</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>, </span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>Student</span></b></code><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><i
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>对象们</span></i><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>的成员将存储这些信息。部分原因是他们是匿名的，是不可以直接访问的类对象。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>另一方面，类变量是用于访问类对象的一种语言特性。虽然在类<i><span style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>变量</span></i>上操作语法，但实际上调度了一个类<i><span
style='border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>对象</span></i>。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>让我们考虑一下我们以前在</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'><a href="http://ddili.org/ders/d.en/value_vs_reference.html"><span
lang=EN-US style='font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><span lang=EN-US>值类型和引用类型章节</span></span></a></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>中看到过的代码：</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>auto</span></span><span
lang=EN-US style='color:black'> variable1 = </span><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>new</span></span><span
lang=EN-US style='color:black'> MyClass;<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>auto</span></span><span
lang=EN-US style='color:black'> variable2 = variable1;<o:p></o:p></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;mso-line-height-alt:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><code><b><span lang=EN-US style='font-size:
14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>new</span></b></code><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>关键字构造了一个匿名的类对象。</span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>variable1</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>和</span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>variable2</span></b></code><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>都只提供对那个匿名对象的访问</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>：</span><span lang=EN-US
style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'> </span>(anonymous MyClass object)<span style='mso-spacerun:yes'>    </span>variable1<span style='mso-spacerun:yes'>    </span>variable2<o:p></o:p></span></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;
background:white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'> ---+-------------------+---<span style='mso-spacerun:yes'>  </span>---+---+---<span style='mso-spacerun:yes'>  </span>---+---+---<o:p></o:p></span></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;
background:white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span>|<span style='mso-spacerun:yes'>        </span>... <span style='mso-spacerun:yes'>       </span>|<span style='mso-spacerun:yes'>        </span>| o |<span style='mso-spacerun:yes'>        </span>| o |<o:p></o:p></span></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;
background:white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'> ---+-------------------+---<span style='mso-spacerun:yes'>  </span>---+-|-+---<span style='mso-spacerun:yes'>  </span>---+-|-+---<o:p></o:p></span></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;
background:white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>              </span></span><span
style='color:black'>▲<span lang=EN-US><span style='mso-spacerun:yes'>                    </span>|<span style='mso-spacerun:yes'>            </span>|<o:p></o:p></span></span></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;
background:white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>              </span>|<span style='mso-spacerun:yes'>                    </span>|<span style='mso-spacerun:yes'>            </span>|<o:p></o:p></span></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;
background:white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>              </span>+--------------------+------------+<o:p></o:p></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><b><span style='font-size:13.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>复制</span></b><b><span
lang=EN-US style='font-size:13.0pt;font-family:Arial;color:#000033'><o:p></o:p></span></b></p>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>复制只影响变量，不是对象。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'><o:p></o:p></span></p>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>因为类是引用类型，定义一个新的类变量做为另一副本，将产生两个变量，它们都能提供对同一对象的访问。不会复制实际的对象。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>.<o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>由于没有对象被复制，</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> postblit</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>函数</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this(this)</span></b></code><span
lang=EN-US> </span><span class=apple-converted-space><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>不能用于类</span></span><span
class=apple-converted-space><u><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:red'>变量</span></u></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>。</span></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>.<o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>auto</span></span><span
lang=EN-US style='color:black'> variable2 = variable1;<o:p></o:p></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>在上面的代码中，</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>variable2</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>由</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>variable1</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>初始化。这两个变量开始提供对同一对象的访问。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></p>

<p style='margin-top:5.0pt;margin-right:12.0pt;margin-bottom:5.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>当实际的对象需要被复制时，类必须有一个为此目地的成员函数。为了与数组兼容，这个函数可以变命名为</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>dup()</span></b></code><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>。该函数必须创建并返回一个新的类对象。让我们看看这个有各种类型成员的类：</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>:<o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>class</span><span lang=EN-US style='color:
black'> Foo<o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black'>{<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span>S<span style='mso-spacerun:yes'>      </span>o; <span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>//</span><span
style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>假定<span lang=EN-US> S </span>是结构类型<span
lang=EN-US><o:p></o:p></span></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>char</span><span lang=EN-US
style='color:black'>[</span><span lang=EN-US>] s;<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>int</span></span><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span>i;<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>// ...<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>(</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>S o, </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>const</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> </span><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'>char</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>[] s, </span><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>int</span></span><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> i)<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>       </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>.o</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> = o;<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>       </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>.s</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> = s.dup;<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>       </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>.i</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> = i;<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>Foo dup() </span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>const</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> <span style='mso-spacerun:yes'>      </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>return</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> </span><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'>new</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> Foo(o, s, i);<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>}<o:p></o:p></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dup()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>成员函数利用</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>Foo</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>的构造函数，创建并返回新的对象。请注意，构造函数通过数组的</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>.dup</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>属性显式复制</span><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>S</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>成员。做为值类型，</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>o</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>和</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>i</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>自动被复制。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>下面的代码演示使用</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dup()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>来创建一个新的对象：</span><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>auto</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> var1 = </span><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>new</span></span><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> Foo(S(1.5), </span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;hello&quot;</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>, 42);<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>auto</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> var2 = var1.dup();<o:p></o:p></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>其结果是，</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>var1</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>and<span class=apple-converted-space>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>var2</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>相关联的对象是不同的。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>同样，可以由命名为</span><span style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> </span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>idup()</span></b></code><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>的适当的成员函数提供</span><code><b><span style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>不可变</span></b></code><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>对象的副本：</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>class</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> Foo<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>{<o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='font-size:
10.0pt;color:green;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'>// ...<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>immutable</span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>(</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>Foo) idup() </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>const</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>       </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>return</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> </span><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'>new</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> </span><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'>immutable</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>(Foo)(o, s, i);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>}<o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>// ...<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>immutable</span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>(</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>Foo) imm = var1.idup();<o:p></o:p></span></pre></div>

</span>

<h6 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:13.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>赋值</span><span
lang=EN-US style='font-size:13.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></h6>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>就像复制，赋值只影响变量。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></p>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>给类变量赋值，会解除变量与当前对象及新对象的关联。</span><span lang=EN-US style='font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></p>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>如何没有别的类变量，它仍提供对已解除关联对象的访问，该对象在将来某个时候将由垃圾回收器销毁。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>auto</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> variable1 = </span><span style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span lang=EN-US
style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>new</span></span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> MyClass();<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>auto</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> variable2 = </span><span style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span lang=EN-US
style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>new</span></span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> MyClass();<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>variable1 </span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;background:#FFFF88'>=</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> variable2;<o:p></o:p></span></pre></div>

<p style='margin-top:5.0pt;margin-right:12.0pt;margin-bottom:5.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>上面的赋值让</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>variable1</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>离开其对象并且开始提供对</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>variable2</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>的对象的访问。由于没有别的变量作为变量</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>variable1</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>的原始对象，该对象将由垃圾回收器销毁。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>赋值操作不能改变类。换句话说，</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>opAssign</span></b></code><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> </span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>不能因为他们而被重载。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></p>

<h6 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:13.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>定义</span><span
lang=EN-US style='font-size:13.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></h6>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>类的定义由</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>class</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>关键字而不是</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>struct</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>关键字</span><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>:<o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>class</span></span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> ChessPiece<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>{<o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>// ...<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>}<o:p></o:p></span></pre></div>

<h6 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:13.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>构造</span><span
lang=EN-US style='font-size:13.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></h6>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>相对于结构，构造函数的名称是</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>。与结构不同，类对象无法由</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>{&nbsp;}</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>语法构造。</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>class</span></span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> ChessPiece</span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>{<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dchar</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> shape;<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>(</span></span><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>dchar</span></span><span lang=EN-US style='color:black;border:
none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'> shape)<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>       </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>.shape</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> = shape;<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>}<o:p></o:p></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>与结构不同的是，构造函数参数按顺序分配给成员时，类不会自动构造对象</span><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>:<o:p></o:p></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>class</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> ChessPiece<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>{<o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dchar</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> shape;<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>size_t value;<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>}<o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>void</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> main()<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>{<o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US style='color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>auto</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> king = </span><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>new</span></span><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> ChessPiece('</span><span
style='font-family:"MS Mincho";mso-bidi-font-family:"MS Mincho";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>♔</span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>', 100); <span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:green;border:
none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>// </span></span><span
class=dcomment><span style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>← <span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'></span></span><span
class=dcomment></span><span style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;background:#FF4040'>编译出错</span><span
lang=EN-US><o:p></o:p></span></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=dcomment><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>}<o:p></o:p></span></span></pre><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
class=dcomment><b><span lang=EN-US style='font-size:10.0pt;color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>Error: no constructor for ChessPiece</span></b></span><span
class=dcomment><b><span style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>（错误：类<span lang=EN-US>ChessPiece </span>没有构造函数）<span
lang=EN-US><o:p></o:p></span></span></b></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>参数显式定义构造函数后，那样的语法才能通过编译。</span></span><span class=dcomment><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<h6 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='font-size:
13.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:
Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>析构</span></span><span class=dcomment><span lang=EN-US
style='font-size:13.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></h6>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>与结构一样，析构函数的名称是</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>~this</span></b></code><span
class=dcomment><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>:<o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
class=dcomment><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>    </span>~</span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>this</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>()</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=dcomment><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>    </span>{<o:p></o:p></span></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=dcomment><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>       </span><span style='mso-spacerun:yes'> </span></span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:green;border:
none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>// ...<o:p></o:p></span></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=dcomment><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></span></pre></div>

<h6 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='font-size:
13.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:
Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>成员访问</span></span><span class=dcomment><span lang=EN-US
style='font-size:13.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></h6>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>与结构一样，由点运算符访问成员：</span></span><span class=dcomment><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
class=dcomment><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span></span><span
class=dcomment><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>auto</span></span><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> king = </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>new</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> ChessPiece('</span></span><span class=dcomment><span
style='font-family:"MS Mincho";mso-bidi-font-family:"MS Mincho";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>♔</span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>');<o:p></o:p></span></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=dcomment><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>    </span>writeln(king</span></span><span
class=dcomment><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm;background:#FFFF88'>.shape</span></span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>);<o:p></o:p></span></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>虽然语法上看起来像访问变量的成员，实际上是对象的成员。类变量没有成员，类对象有。</span></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>king</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>变量并没有</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>shape</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>成员，匿名对象有。</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman"'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p>&nbsp;</o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=dcomment><b><i><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>注意</span></i></b></span><span class=dcomment><b><i><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>:</span></i></b></span><span
class=apple-converted-space><i><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></i></span><span class=dcomment><i><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>在上面的代码中，一般不这样直接访问成员。若确实需要这样的语法，应该首选属性，这将在后面的章节中解释。</span></i><span
lang=EN-US><o:p></o:p></span></span></p>

<h6 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='font-size:
13.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:
Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>运算符重载</span></span><span class=dcomment><span lang=EN-US
style='font-size:13.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></h6>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>虽然</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>opAssign</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>不能被类重载，但与结构一样，可以实现运算符重载。对于类，</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>opAssign</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>意味着一个类变量总是关联着一个类对象。</span></span><span class=dcomment><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<h6 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='font-size:
13.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:
Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>成员函数</span></span><span class=dcomment><span lang=EN-US
style='font-size:13.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></h6>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>成员函数一般与结构相同。</span></span><span class=dcomment><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>不同的是某些成员函数自动继承自</span></span><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>Object</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>类。下一章我们将看到如何通过修改</span></span><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>override</span></b></code><span
class=dcomment><span style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>关键字来定义</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>toString</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>函数。</span></span><span class=dcomment><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=dcomment><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p>&nbsp;</o:p></span></span></p>

<h6 style='margin-top:0cm;margin-right:6.0pt;margin-bottom:0cm;margin-left:
6.0pt;margin-bottom:.0001pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><code><span lang=EN-US style='font-size:15.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>is</span></code><span class=apple-converted-space><span
lang=EN-US style='font-size:13.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><span
class=dcomment><span style='font-size:13.0pt;mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>和</span></span><span
class=apple-converted-space><span lang=EN-US style='font-size:13.0pt;
font-family:Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:15.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>!is</span></code><span
class=apple-converted-space><span lang=EN-US style='font-size:13.0pt;
font-family:Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&nbsp;</span></span><span class=dcomment><span
style='font-size:13.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>运算符</span></span><span
class=dcomment><span lang=EN-US style='font-size:13.0pt;font-family:Arial;
color:#000033;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></span></h6>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>这些运算符操作在类变量上。</span></span><span class=dcomment><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;mso-line-height-alt:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>is</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>指定两个类变量是否提供对同一类对象的访问。</span></span><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>若是同一对象返回</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>true</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>，否则为</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>false</span></b></code><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>。</span></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>!is</span></b></code><span
class=dcomment><span style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>与</span></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>is</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>相反。</span></span><span class=dcomment><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
class=dcomment><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span></span><span
class=dcomment><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>auto</span></span><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> myKing = </span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>new</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> ChessPiece('</span></span><span class=dcomment><span
style='font-family:"MS Mincho";mso-bidi-font-family:"MS Mincho";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>♔</span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>');<o:p></o:p></span></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=dcomment><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>auto</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> yourKing = </span></span><span style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span class=dcomment><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>new</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> ChessPiece('</span></span><span class=dcomment><span
style='font-family:"MS Mincho";mso-bidi-font-family:"MS Mincho";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>♔</span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>');<o:p></o:p></span></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=dcomment><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>assert</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>(</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>myKing !</span></span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>is</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> yourKing);</span><span lang=EN-US><o:p></o:p></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>myKing</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>和</span></span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>yourKing</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>变量是不同的对象，</span></span><span class=dcomment><span
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> </span></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>!is</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>运算符返回</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>true</span></b></code><span
class=dcomment><span style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>。</span></span><span
class=dcomment><span style='font-family:"Times New Roman";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'> </span></span><span
class=dcomment><span style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>即使两个对象由同一字符</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>'</span></b></code><code><b><span lang=EN-US
style='font-size:14.5pt;font-family:"MS Mincho";mso-bidi-font-family:"MS Mincho";
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>♔</span></b></code><code><b><span lang=EN-US style='font-size:
14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>'</span></b></code><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>，他们仍然是两个单独的对象。</span></span><span class=dcomment><span lang=EN-US
style='font-family:"Times New Roman"'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>当变量提供对同一对象的访问时，</span></span><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>is</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>返回</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>true</span></b></code><span
class=dcomment><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>:<o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
class=dcomment><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span></span><span
class=dcomment><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>auto</span></span><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> myKing2 = myKing;<o:p></o:p></span></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=dcomment><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>assert</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>(</span><span lang=EN-US style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>myKing2 </span></span></span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>is</span></span><span
lang=EN-US style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> myKing);</span><span lang=EN-US><o:p></o:p></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>以上的两个变量提供对同一对象的访问。</span></span><span class=dcomment><span
lang=EN-US style='font-family:"Times New Roman"'><o:p></o:p></span></span></p>

<h5 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=dcomment><span style='font-size:
15.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:
Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>摘要</span></span><span class=dcomment><span lang=EN-US
style='font-size:15.0pt;font-family:Arial;color:#000033;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></h5>

<p class=MsoNormal style='margin-top:6.0pt;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l1 level1 lfo4;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:
Symbol;color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span></span><![endif]><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>类和结构虽然有共同特点，但还是有很大的差异。</span></span><span
class=dcomment><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l1 level1 lfo4;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:
Symbol;color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span></span><![endif]><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>类是引用类型。</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>new</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>关键字构造一个匿名</span></span><span
class=dcomment><i><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>类对象</span></i></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>并返回一个<i>类变量</i>。</span></span><span class=dcomment><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l1 level1 lfo4;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:
Symbol;color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span></span><![endif]><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>不与任何对象相关联的类变量为</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>null</span></b></code><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>。检查</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>null</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>必须使用</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>is</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>或者</span></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>!is</span></b></code><span
class=dcomment><span style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>，而不是</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>==</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>或者</span></span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>!=</span></b></code><span class=dcomment><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>。</span></span><span class=dcomment><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l1 level1 lfo4;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:
Symbol;color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span></span><![endif]><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>复制操作将增加一个与对象关联的变量。为了复制类对象，类型必须有一个命名为</span></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>dup()</span></b></code><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>的特殊函数。</span></span><span
class=dcomment><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-top:6.0pt;margin-right:12.0pt;margin-bottom:
0cm;margin-left:24.0pt;margin-bottom:.0001pt;text-indent:-18.0pt;line-height:
14.25pt;mso-list:l1 level1 lfo4;tab-stops:list 36.0pt;vertical-align:baseline'><![if !supportLists]><span
class=dcomment><span lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:
Symbol;color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span></span><![endif]><span class=dcomment><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>赋值会把一个变量与一个对象相关联。该行为不能被更改。</span></span><span
class=dcomment><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></span></p>

<p class=MsoNormal align=center style='text-align:center;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=dcomment><span lang=EN-US
style='font-size:11.0pt;font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>[</span></span><span
class=apple-converted-space><span lang=EN-US style='font-size:11.0pt;
font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><span
class=dcomment><span lang=EN-US style='font-size:11.0pt;font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><a href="operatoroverloading.html" style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span lang=EN-US
style='font-size:10.5pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";color:purple;text-decoration:none;
text-underline:none'><span lang=EN-US>前页</span></span><span style='font-size:
10.5pt;color:purple;text-decoration:none;text-underline:none'>&nbsp;</span></a>]
&nbsp; [</span></span><span class=apple-converted-space><span lang=EN-US
style='font-size:11.0pt;font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><span
class=dcomment><span lang=EN-US style='font-size:11.0pt;font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><a href="inheritance.html" style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span lang=EN-US
style='font-size:10.5pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";color:purple;text-decoration:none;
text-underline:none'><span lang=EN-US>后页</span></span><span style='font-size:
10.5pt;color:purple;text-decoration:none;text-underline:none'>&nbsp;</span></a>]<o:p></o:p></span></span></p>

</span></div>

</body>

</html>
